﻿package mortal.game.view.task.drama.operations
{
    import Message.DB.Tables.*;
    import flash.geom.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.game.scene3D.ai.*;
    import mortal.mvc.core.*;

    public class TaskDramaPlayerScreenMove extends Object implements ITaskDramaStepCommand
    {
        private var _callback:Function;
        private var _myData:TTaskDrama;

        public function TaskDramaPlayerScreenMove()
        {
            return;
        }// end function

        public function call(param1:TTaskDrama, param2:Function = null) : void
        {
            this._myData = param1;
            this._callback = param2;
            AIManager.cancelAll();
            var _loc_3:* = new Point(param1.valueOne, param1.valueTwo);
            AIManager.addMoveTo(_loc_3, 0);
            Dispatcher.addEventListener(EventName.AI_MoveEnd, this.aiMoveEndHandler);
            AIManager.start();
            return;
        }// end function

        private function aiMoveEndHandler(event:DataEvent) : void
        {
            Dispatcher.removeEventListener(EventName.AI_MoveEnd, this.aiMoveEndHandler);
            if (this._callback != null)
            {
                this._callback.apply();
                this._callback = null;
            }
            return;
        }// end function

        public function cancel(param1:TTaskDrama, param2:Function = null) : void
        {
            this._callback = param2;
            return;
        }// end function

        public function dispose() : void
        {
            Dispatcher.removeEventListener(EventName.AI_MoveEnd, this.aiMoveEndHandler);
            return;
        }// end function

    }
}
